package com.pa165.languageschoolservice.DTO;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author Tomas Hruby This class represents data transfer object for Lecture in
 * language school.
 */
@XmlRootElement
public class LectureDTO implements Serializable {

    private Long id;
    private String roomNumber;
    private String name;
    private Date startTime;
    private Date endTime;
    private LectorDTO lector;
    private CourseDTO course;

    public CourseDTO getCourse() {
        return course;
    }

    public void setCourse(CourseDTO course) {
        this.course = course;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(String roomNumber) {
        this.roomNumber = roomNumber;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public LectorDTO getLector() {
        return lector;
    }

    public void setLector(LectorDTO lector) {
        this.lector = lector;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof LectureDTO)) {
            return false;
        }
        LectureDTO other = (LectureDTO) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 59 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        String formatString = "yyyy-MM-dd H:mm";
        SimpleDateFormat sdfSource = new SimpleDateFormat(formatString);
        String res = "LectureDTO:{" + "id=" + id + ", name=" + name + ", roomNumber=" + roomNumber + ", start=" + sdfSource.format(startTime) + ", end=" + sdfSource.format(endTime);
        if(course != null){
            res += ", " + course.toString();
        }
        if(lector != null){
            res += ", " + lector.toString();
        }
        res += "}";
        return res;
    }
}
